package cn.edu.xmu.oomall.payment.microservice.vo;

import cn.edu.xmu.oomall.payment.microservice.bo.WeChatPayRefund;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.tomcat.util.compat.JreCompat;
import org.checkerframework.checker.units.qual.C;

import java.time.LocalDateTime;

/**
 * @author ziyi guo
 * @date 2021/12/1
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class RefundNotifyRetVo {
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public class Resource{
        @Data
        @NoArgsConstructor
        @AllArgsConstructor
        public class Ciphertext{
            @Data
            @NoArgsConstructor
            @AllArgsConstructor
            public class Amount{
                private Integer total;
                private Integer refund;
                private Integer payerTotal;
                private Integer payerRefund;
            }

            private String mchid;
            private String outTradeNo;
            private String transactionId;
            private String outRefundNo;
            private String refundId;
            private String refundStatus;
            private String userReceivedAccount;
            private Amount amount;

        }

        private String algorithm;
        private String originalType;
        private Ciphertext ciphertext;
        private String nonce;
    }

    private String id;
    @JsonFormat(shape = JsonFormat.Shape.STRING,pattern ="yyyy-MM-dd'T'HH:mm:ss.SSS" ,timezone = "GMT+8")
    private LocalDateTime createTime;
    private String eventType;
    private String summary;
    private String resourceType;
    private Resource resource;


//    public RefundNotifyRetVo(WeChatPayRefund weChatPayRefund){
//        this.id = "EV-2018022511223320873";
//        this.createTime = LocalDateTime.now();
//        this.eventType = "Refund." + weChatPayRefund.getStatus();
//        this.summary = null;
//        this.resourceType = null;
//        this.resource = new Resource("AEAD_AES_256_GCM","transaction",
//                new Resource.Ciphertext("1230000109", weChatPayRefund.getOutTradeNo(), "1217752501201407033233368018", weChatPayRefund.getOutRefundNo(), "1217752501201407033233368018", weChatPayRefund.getStatus(), "招商银行信用卡0403",
//                       new Resource.Ciphertext.Amount(weChatPayRefund.getTotal(), weChatPayRefund.getRefund(), weChatPayRefund.getPayerTotal(), weChatPayRefund.getPayerRefund())),
//                "fdasfjihihihlkja484w");
//    }

}


